package com.acme.bankapp.domain.bank;

public abstract class AbstractAccount implements Account {
	static final String MES_NEGATIVE_BALANCE = "Balance must be positive or zero value";
	static final String MES_NEGATIVE_DEPOSIT = "Number of deposit must be positive value";
	static final String MES_TOO_SMALL_BALANCE = "Balance is less than required value";
	
	protected double balance;
	
	protected AbstractAccount(double balance) throws Exception {
		if (balance < 0)
			throw new Exception(MES_NEGATIVE_BALANCE);
		this.balance = balance;
	}
	
	public void deposit(double x) throws Exception {
		if (x < 0)
			throw new Exception(MES_NEGATIVE_DEPOSIT);
		
		this.balance += x;
	}
	
	public abstract void withDraw(double x) throws Exception;
	
	public abstract double maximumAmountToWithdraw();
	
	public double getBalance() {
		return balance;
	}
}
